package co.crossoft.exposeServiceImpl;

import co.crossoft.daoImpl.MaterialDaoImpl;
import co.crossoft.domain.MaterialBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import service.ExposeMaterialConfigService;


/**
 * Created by Snow on 8/11/2017.
 */
@Component
public class ExposeMaterialConfigServiceImpl implements ExposeMaterialConfigService {

    @Autowired
    MaterialDaoImpl materialDaoImpl;

    @Override
    public String getMaterialList(String id,String quid,String plant) {
        String retString = materialDaoImpl.getMaterialList(id,quid,plant);
        return retString;
    }

    @Override
    public String saveMaterialData(String curVersion,String id,String name,
                                  String plant,String bomFk,String matTypeFk,String version,String measureUnit,
                                  String lotSize,String srcStatusFk,String routerFk,String qtyLimit,String baseUnit,String statusFk) {
        MaterialBean materialBean = new MaterialBean();
        materialBean.setQuid("MATERIAL:"+plant+","+id+","+version);
        materialBean.setId(id);
        materialBean.setName(name);
        materialBean.setPlant(plant);
        materialBean.setCurVersion(curVersion);
        materialBean.setBomFk(bomFk);
        materialBean.setMatTypeFk(matTypeFk);
        materialBean.setVersion(version);
        materialBean.setMeasureUnit(measureUnit);
        materialBean.setLotSize( Double.parseDouble(lotSize) );
        materialBean.setSrcStatusFk(srcStatusFk);
        materialBean.setRouterFk(routerFk);
        materialBean.setQtyLimit(qtyLimit);
        materialBean.setBaseUnit(baseUnit);
        materialBean.setStatusFk(statusFk);
        String retString = materialDaoImpl.saveMaterialData(materialBean);
        return retString;
    }

    @Override
    public String deleteMaterial(String quid) {
        String retString = materialDaoImpl.deleteMaterial(quid);
        return retString;
    }
}
